<?php

namespace mbilling\BillingBundle\Model;

use Doctrine\ORM\EntityManager;
use mbilling\BillingBundle\Entity\bases;


Class BasesModel
{
    protected $em;

    public function __construct(EntityManager $em)
    {
        $this->em = $em;
    }
    
    public function findAll()
    {
        $databases = $this->em->getRepository('BillingBundle:bases')->findAll();
        return $databases;
    }
    
    public function FindByPK($database_id)
    {
        $database = $this->em->find('BillingBundle:bases', $database_id);
        return $database;
    }

    public function findByOrderId($order_id)
    {
        $database = $this->em->getRepository('BillingBundle:bases')->findBy(array('order_id' => $order_id));
        return $database;
    }
    
    public function create($oEntity)
    {    
        $this->em->persist($oEntity);
        $this->em->flush();
    }
    
    public function removeByPK($database_id)
    {
        $database = $this->em->find('BillingBundle:bases', $database_id);
        $this->em->remove($database);
        $this->em->flush();
    }
}
?>
